

/*
 * tab切换 使用方法： tab都用slidetab_作为ID的前缀，如 "sildetab_categories_products"
 * 默认选中的tab使用selected作为class class="selected" 被切换的内容默认请都加上
 * style="display:none"，程序会根据selected让对应的显示
 * 被切换的内容的对应ID请在tab的id后面加_c如，sidetab_categories_products_c
 */
$(function() {
	$(document).ready(function() {
		$("*[id^=sildetab_]").each(function(i) {
			if ($(this).hasClass('on')) {
				$('#' + $(this).attr('id') + '_c').show();
			}
		})
	});

	$("*[id^=sildetab_]").click(function() {
		if ($('#' + $(this).attr('id') + '_c').is(":hidden")) {
			$("*[id^=sildetab_]").each(function(i) {
				$('#' + $(this).attr('id') + '_c').slideUp("fast");
				$(this).removeClass('on');
			});
			$('#' + $(this).attr('id') + '_c').slideDown("fast");
			$(this).addClass('on');
		}
	});
});
function changetab(gid,theid){
		if ($('#' + theid + '_c').is(":hidden")) {
			$("*[id^="+gid+"]").each(function(i) {
				$('#' + $(this).attr('id') + '_c').slideUp("fast");
				$(this).removeClass('on');
			});
			$('#' + theid + '_c').slideDown("fast");
			$('#' + theid).addClass('on');
		}

}
function changeverify() {
    var date = new Date();
    var ttime = date.getTime();
    var url = U('home/Public/verify');
    $('#verifyimg').attr('src',url+'&'+ttime);
}

function ajaxupload(obj,opt) {
	var left = $(obj).offset().left;
	var top = $(obj).offset().top;
	publish_type_html = '<div id="upload_selectpic"><div class="btn_green" href="javascript:void(0);" >从电脑选择图片'+
						'<form action=\'{:U("weibo/plugins/before_publish")}\' enctype="multipart/form-data" method="post" id="uploadpic">'+
						'<input type="file" hidefoucs="true" name="pic" onchange="weibo.plugin.image.upload(this)"><input type="hidden" name="plugin_id" value="1">'+
						'</form></div><div>仅支持JPG、GIF、PNG、JPEG图片文件，且文件小于2M</div></div><div class="alC pt10 pb10 f14px" id="upload_loading" style="display:none"><img src="'+ _THEME_+'/images/icon_waiting.gif" width="20" class="alM"> 正在上传中...<br /><a class="btn_w mt10" href="javascript:void(0)" onclick="$(\'div .talkPop\').remove();stopAjax();">取消上传</a></div>';
	var html = '<div class="talkPop" style="left:'+ left +'px;top:'+ top +'px"><div  style="position: relative; height: 7px; line-height: 3px;">'
		     + '<img class="talkPop_arrow" style="margin-left:5px;position:absolute;" src="__THEME__/images/zw_img.gif" /></div>'
             + '<div class="talkPop_box">'
			 + '<div class="close"><a href="javascript:void(0)" class="del" onclick=" delTypeBox()" > </a></div>'
			 + '<div id="publish_type_content">'+publish_type_html+'</div>'
			 + '</div></div>';
	$("#addenterprise").after( html );
}
function uploadafile(obj,opt) {

			//	  <a href="javascript:;" onclick="uploadafile(this,{pinfo:'aaa'});" class="pic" title="仅支持JPG、GIF、PNG、JPEG图片文件，且文件小于2M" >上传LOGO</a></div>


	var upform = '<form action=\'{:U("weibo/plugins/before_publish")}\' enctype="multipart/form-data" method="post" id="uploadafileform">'+
						'<input type="file" hidefoucs="true" name="pic" onchange="alert(\'OOOK\')">'+
						'</form>'+
						'<div class="alC pt10 pb10 f14px" id="upload_loading" style="display:none"><img src="'+ _THEME_+'/images/icon_waiting.gif" width="20" class="alM"> 正在上传中...<br /><a class="btn_w mt10" href="javascript:void(0)" onclick="$(\'div .talkPop\').remove();stopAjax();">取消上传</a></div>';
			if($('#uploadafileform').length){
			}else{
				jQuery(upform)
				.appendTo(document.body);
			}
			$('#uploadafileform:input').attr('hidefoucs',false);
}
function uploadlayershow(obj) {
	var upform = '<div id="uploadfloatpic" class="uploadfloatpic" href="javascript:void(0);" title="dd">上传头像'+
				'<form action=\'{:U("weibo/plugins/before_publish")}\' enctype="multipart/form-data" method="post" id="uploadafileform">'+
						'<input type="file" hidefoucs="true" name="pic" onchange="alert(\'OOOK\')">'+
						'</form>'+
					'</div>';
			if($('#uploadfloatpic').length){
			}else{
				jQuery(upform)
				.appendTo(document.body);
			}
		//	$('#uploadfloatpic').show();
			$('#uploadfloatpic').css('left',$(obj).offset().left + 1);
			$('#uploadfloatpic').css('top',$(obj).offset().top + $(obj).height() - 19);
			$('#uploadfloatpic').css('width',$(obj).width());
			$('#uploadfloatpic').removeClass('uploadfloatpic');
			$('#uploadfloatpic').addClass('uploadfloatpicover');
			$('#uploadfloatpic').show();
}
function uploadlayerhide() {
	$('#uploadfloatpic').hide();
}

// 删除类型框
function delTypeBox(){
	$('.talkPop').remove();
}
